Jump to content

Recommended Posts

I can do a prefab postinit just fine, but I've never seen a stategraph postinit besides Dana Addams' Link mod. But that's adding complete new states and I'll admit, I'm not quite familiar enough with postinits to understand what to change about it, if anything at all. So, I have two questions:

 

Is it possible to create a stategraph postinit to edit an existing event and state? 

In this case, editing the doattack event to make a custom bow state like this:

    EventHandler("doattack", function(inst)        if not inst.components.health:IsDead() and not inst.sg:HasStateTag("attack") then            local weapon = inst.components.combat and inst.components.combat:GetWeapon()            if weapon and weapon:HasTag("blowdart") then                inst.sg:GoToState("blowdart")            elseif weapon and weapon:HasTag("thrown") then                inst.sg:GoToState("throw")            elseif weapon and weapon:HasTag("bow") then                inst.sg:GoToState("bow")            else                inst.sg:GoToState("attack")            end        end    end),

 and the attack state itself to add some neat combo-y things to a specific character.

 

If it's possible, any help at all would be greatly appreciated.

Help can range to just a poke in the right direction to an example. An example would work well since that's how I learn best. 

 

Thanks for reading, and even more thanks if you can (even if it doesn't work) help me!

post-286034-0-37736900-1395815198_thumb.

You could do something like this:

AddStategraphPostInit("wilson", function(sg)	local old_doattack = sg.events.doattack.fn	sg.events.doattack.fn = function(inst, data)		if not inst.components.health:IsDead() and not inst.sg:HasStateTag("attack") then			local weapon = inst.components.combat and inst.components.combat:GetWeapon()			if weapon and weapon:HasTag("bow") then				inst.sg:GoToState("bow")			else				return old_doattack(inst, data)			end		end	endend)AddStategraphState("wilson", GLOBAL.State {	name = "bow",	onenter = function(inst)		print("hi")	end,	onexit = function(inst)		print("bye")	end,})

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...